﻿var AuthenUrl = "";//鉴权中心URL
var AuthenType = "1"; // 0  调用本地数据库的，1调用鉴权中心
var sessionName = "MidEdn_Token";

function AuthenLoad() {
    debugger
    var LoginToken = window.location.href.split("=")[1];
    //换取AccessToken
    if (LoginToken != undefined && LoginToken != 'undefined' && LoginToken != "") {
        ConvertToken(LoginToken);
    }
}
function ConvertToken(LoginTokens) {
    var token = LoginTokens.split("#")[0];
    $.ajax({
        type: "POST",
        url: AuthenUrl + "api/Power/ConvertToken?strLoginToken=" + token,
        dataType: "json",
        async: false,
        success: function (RtnData) {

            if (RtnData.errCode == 0) {
                var AccessToken = RtnData.data.AccessToken;
                console.log("AccessToken    " + AccessToken);
                if (AccessToken != "" && AccessToken != undefined) {
                    sessionStorage.setItem(sessionName, AccessToken);
                } else {
                    window.location.href = AuthenUrl + "DefaultCT.html";
                }

            }
        },
        error: function (RtnData) {
            window.location.href = AuthenUrl + "DefaultCT.html";
            layer.msg(RtnData.result);
        }
    })
}



